<!-- 录用列表 -->
<template>
    <div class="page-box h100 display-flex czbj">
      <p class="title-label mb10">录用列表</p>
      <dxtable
        :dataJson="dataJson"
        :portUrl="portUrl"
        :formJson="formJson"
        :qx="qx"
        ref="databale"
        :czFun="czFun"
      ></dxtable>

      <n-modal v-model:show="showModal" preset="card" class="dfsrtrtrt">
      <template #header>
        <div>重新招聘</div>
      </template>
      <div>
        <p>当前录用人</p>
        <div class="fsdfsdrtdsd mt20">
          <div class="">id：{{ usjeder.id }}</div>
          <div class="">姓名：{{ usjeder.name }}</div>
          <div class="">
            等级：{{ usjeder.dengji == 2 ? "VIP" : "普通用户" }}
          </div>
          <div class="">手机号：{{ usjeder.phone }}</div>
          <div class="">邮箱：{{ usjeder.email }}</div>
          <div class="">录用时间：{{ usjeder.lysj }}</div>
          <div class="">
            简历：<a :href="usjeder.jianli" class="sz ls" target="_blank"
              >点击查看</a
            >
          </div>
        </div>
        <div class="mt20">
          <n-input
            v-model:value="dfsfrtertert"
            rows="5"
            type="textarea"
            placeholder="请输入重新招聘理由"
          />
        </div>
      </div>
      <template #action>
        <div class="tr">
          <n-button type="info" @click="tijisdrtre" :loading="kdfssdf">
            提交
          </n-button>
          <n-button class="ml20" @click="showModal = false"> 取消 </n-button>
        </div>
      </template>
    </n-modal>
    </div>
  </template>
  <script lang="ts" setup>
  import { Options } from "@vicons/ionicons5";
  import dxtable from "../../components/util/dxtable.vue";
  import sort from "../../components/util/sort.vue";
  import {
    dxget,
    dxpost,
    transferTimeYMDHm,
    dialog,
    dxdel,
  } from "../../util/index";
  import { NButton, NImage, NTag } from "naive-ui";
  import { h, ref, reactive, render } from "vue";
  const databale = ref();
  const showModal = ref(false);
const usjeder = ref(null);
const dfsfrtertert= ref()
  const dqobj = ref({});
  const kdfssdf = ref(false);
  const initeer = () => {
    databale.value.initDataExpose();
  };
  
  let dataJson = [
    {
      title: "职位名称",
      key: "miansi.zwid",
      width: "",
      type: "select",
      options: [],
      search: true,
      istable: true,
      required: false,
      render: (row) => {
        return row.name;
      },
    },
    // {
    //   title: "试用期价格",
    //   key: "syqjg",
    //   width: "",
    //   search: false,
    //   istable: true,
    //   required: false,
    // },
    // {
    //   title: "薪资待遇",
    //   key: "xzdy",
    //   width: "",
    //   search: false,
    //   istable: true,
    //   required: false,
    // },
    // {
    //   title: "工作地点",
    //   width: "",
    //   search: false,
    //   istable: true,
    //   required: false,
    //   render: (row) => {
    //     return row.sheng + "-" + row.shi;
    //   },
    // },
    {
      title: "录用人姓名",
      key: "miansi.uid",
      type: "select",
      options: [],
      search: true,
      istable: true,
      required: false,
      width: 150,
      render(row) {
        return row.uname;
      },
    },
    {
      title: "录用人电话",
      key: "phone",
      search: false,
      istable: true,
      width: 150,
      required: false,
    },
    {
      title: "录用时间",
      key: "lysj",
      width: 150,
    },{
      title: "工作地点",
      key: "lysj",
      render(row){
        return row.sheng+"-"+row.shi
     }
    },
     {
    title: "简历地址",
    width: 100,
    render(row) {
      return h(
        "span",
        {
          class: "ls sz",
          onClick() {
            open(row.jltext);
          },
        },
        "点击查看"
      );
    },
  },
    
  ];
  
  const qx = {
    DeletePermissionID: "23456", //删除
    EditPermissionIdentifier: "23456", // 编辑
    NewPermissionIdentifier: "23456", // 新建
    ViewPermissionID: "jyczhaopingck", // 查看
  }
  const portUrl = "jyc/miansi/miansi?miansi.luyong=2&b.zpzt=2";
  
  let formJson = reactive([]);
  const czFun = {
    fun: (row) => {
      return [
        h(
          NButton,
          {
            type: "info",
            quaternary: true,
            onClick: async (e) => {
              const { data } = await dxget("jyc/jycadmin/getjsdfd", {
                uid: row.uid,
                id: row.zwid,
              });
              showModal.value = true;
              usjeder.value = data;
            },
          },
          "解雇"
        ),
      ];
    },
  };
  
  const getgetuserList = async () => {
    const { data }: any = await dxget("jyc/api/getuserList");
    dataJson[1].options = [
      {
        label: "全部",
        value: "",
      },
      ...data,
    ];
  };
  getgetuserList();
  
  const getzhiwei = async () => {
    const { data }: any = await dxget("jyc/api/getzhiwei");
    dataJson[0].options = [
      {
        label: "全部",
        value: "",
      },
      ...data,
    ];
  };
  getzhiwei();



  const tijisdrtre = async () => {
  if (!dfsfrtertert.value) {
    window.$message.error("重新招聘理由不能为空");
    return;
  }
  kdfssdf.value = true;
  await dxpost(
    "jyc/miansi/miansi",
    {
      id: usjeder.value.msid,
      cxzpbz: dfsfrtertert.value,
      cxzpsj: transferTimeYMDHm(),
      luyong: 3,
    },
    "put"
  );
  await dxpost(
    "jyc/zhaoping/zhaoping",
    {
      id: usjeder.value.zwid,
      zpzt: 1,
      ypzid: 0,
    },
    "put"
  );
  try {
    await dxpost("jyc/jycadmin/putongrizhi", {
      id: usjeder.value.id,
      name:usjeder.value.zwname,
      beizhu: "很抱歉，您已被解雇了，该职位重新录用了",
      czlx: "取消录用",
    });
  } catch (e) {}
  kdfssdf.value = false;
  showModal.value = false
  initeer();
};
  </script>
  <style scoped></style>
  